package com.qd.qx.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


/*
 * 文件名:    SqliteHelper
 * 创建者:    ys
 * 描述:     TODO 创建数据库
 */
public class SqliteHelper extends SQLiteOpenHelper {

    public static String TABLE = "chatMessage";//聊天信息表

    public SqliteHelper(Context context) {
        super(context, "smack.db", null, 1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table user(user_id  INTEGER primary key autoincrement,user_name varchar,user_psd varchar,user_head_img varchar,login_name varchar,real_name varchar)");
        db.execSQL("create table msg_list(msg_list_id  INTEGER primary key autoincrement,user_id INTEGER,to_name varchar,last_msg varchar,last_msg_time varchar,msg_list_type INTEGER,unread_count INTEGER,top_time varchar,real_name varchar)");
        //db.execSQL("create table msg(msg_id INTEGER primary key autoincrement,msg_list_id  INTEGER,from_name varchar,msg_content varchar,msg_time varchar,msg_type varchar ,from_type INTEGER)");
        db.execSQL("create table msg(msg_id INTEGER primary key autoincrement,msg_list_id  INTEGER,msg_chatid varchar,from_name varchar," +
                "msg_content varchar,msg_sendtime varchar,msg_type varchar " +
                ",from_type INTEGER,send_state INTEGER,header varchar,real_name varchar)");
       // db.execSQL("create table people_info(people_id  INTEGER primary key autoincrement,user_name varchar,img_url varchar,real_name varchar,update_time varchar)");
        db.execSQL("create table chat_config(config_id  INTEGER primary key autoincrement,user_code varchar,only_chatid varchar,is_ring INTEGER,is_membername INTEGER,is_save INTEGER)");
        db.execSQL("create table group_info(groupinfo_id  INTEGER primary key autoincrement,user_name varchar,real_name varchar,img_url varchar,members varchar,update_time varchar)");
        //        db.execSQL("create table msg_list(msg_list_id  INTEGER primary key autoincrement,user_id INTEGER,to_name varchar,last_image varchar,last_img_time varchar,msg_list_type, foreign key (user_id) references  user(user_id) on delete cascade on update cascade )");
//        db.execSQL("create table msg(msg_id INTEGER primary key autoincrement,msg_list_id  INTEGER,from_name varchar,msg_content varchar,msg_time varchar,msg_type varchar, foreign key (msg_list_id) references  msg_list(msg_list_id) on delete cascade on update cascade )");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

}
